package core;

import gitobject.Tree;
import repository.Repository;

import java.io.File;
import java.io.IOException;

public class JitHash {
    /**
     * Generate a hash file in your repository.
     * @param filename
     * @throws IOException 
     */
    @SuppressWarnings("unused")
	public static void hash(String filename) throws IOException {
        /* Todo: You should pass the filename in this function, and generate a hash file in your repository.
        *   Add your code here.*/
    	File dir = new File(filename);
        if(dir.exists()){
			try {
				Tree tree = new Tree(dir);
				tree.writeTree();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			System.out.println("Hash file has been generated successfully.");
        }
        else {
        	throw new IOException("filename is not exist, please check");
        }
    }
}
